package com.steel.yfmall.cloud.assistant.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.steel.yfmall.cloud.assistant.BackstageConstants;
import com.steel.yfmall.cloud.assistant.api.stock.ZgOrderService;
import com.steel.yfmall.cloud.assistant.bean.param.ZgOrderParamBean;
import com.steel.yfmall.cloud.assistant.bean.param.zg.APIParaWarrantyBean;
import com.steel.yfmall.cloud.assistant.bean.result.*;
import com.steel.yfmall.cloud.assistant.common.CommonPublicInfoService;
import com.steel.yfmall.cloud.assistant.common.DepotInfoBeanService;
import com.steel.yfmall.cloud.assistant.dto.para.oms.ParaMasterOrderInfo;
import com.steel.yfmall.cloud.assistant.dto.para.user.ParaSendSmsInfoBean;
import com.steel.yfmall.cloud.assistant.dto.para.user.ParaUserCompanyBean;
import com.steel.yfmall.cloud.assistant.dto.result.goods.ProductSellerGoodsResult;
import com.steel.yfmall.cloud.assistant.dto.zg.ZgCallWsdlAPIBaseDTO;
import com.steel.yfmall.cloud.assistant.dto.zg.ZgWsdlResponseBaseBean;
import com.steel.yfmall.cloud.assistant.dto.zg.order.ZgOrderDetail;
import com.steel.yfmall.cloud.assistant.dto.zg.order.ZgOrderMainBean;
import com.steel.yfmall.cloud.assistant.dto.zg.result.ZgResultBean;
import com.steel.yfmall.cloud.assistant.dto.zg.result.ZgResultOrderConfirmBean;
import com.steel.yfmall.cloud.assistant.goods.*;
import com.steel.yfmall.cloud.assistant.goods.mapper.ProductLibCategoryExtMapper;
import com.steel.yfmall.cloud.assistant.oms.*;
import com.steel.yfmall.cloud.assistant.po.common.DepotInfoBean;
import com.steel.yfmall.cloud.assistant.po.goods.*;
import com.steel.yfmall.cloud.assistant.po.oms.*;
import com.steel.yfmall.cloud.assistant.po.user.UserCompany;
import com.steel.yfmall.cloud.assistant.user.UserCompanyService;
import com.steel.yfmall.cloud.assistant.user.SmsInfoBeanService;
import com.steel.yfmall.cloud.assistant.utils.constants.EnumZgAPINames;
import com.steel.yfmall.cloud.assistant.utils.constants.ZgConstants;
import com.steel.yfmall.cloud.assistant.utils.zg.ZgCallServiceUtils;
import com.steel.yfmall.cloud.assistant.utils.zg.ZgMethodBeanUtil;
import com.steel.yfmall.cloud.assistant.utils.zg.ZgParamUtils;
import com.steel.yfmall.cloud.assistant.view.WarrantyService;
import com.steel.yfmall.cloud.common.bean.param.APIParamMallConfigBean;
import com.steel.yfmall.cloud.common.bean.result.APIResultMallConfigBean;
import com.steel.yfmall.cloud.components.mq.service.MqSendService;
import com.steel.yfmall.cloud.components.utils.base.APIMsgBean;
import com.steel.yfmall.cloud.components.utils.base.Pages;
import com.steel.yfmall.cloud.components.utils.base.ResponseCode;
import com.steel.yfmall.cloud.components.utils.utils.PriceUtils;
import com.steel.yfmall.cloud.components.utils.utils.ResultCodeConstants;
import com.steel.yfmall.cloud.components.utils.utils.UtilDate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @version 1.0
 * @ClassName: ZgOrderServiceImpl
 * @author: TQ
 * @Description: DOTO
 * @Date Create in 14:59 2020/11/19
 **/
@Service
@Slf4j
public class ZgOrderServiceImpl implements ZgOrderService {

    /**
     * 合同预览
     *
     * @param zgOrderParamBean 订单号	masterOrderSn
     * @return 合同地址    filePath
     */
    @Override
    public APIMsgBean<ContractInfoBean> orderShowPdf(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<ContractInfoBean> resultOrderInfoAPIMsgBean = new APIMsgBean<>();
        ContractInfoBean contractInfoBean = new ContractInfoBean();

        if (zgOrderParamBean == null || StringUtils.isBlank(zgOrderParamBean.getMasterOrderSn())) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("参数异常，订单号不能为空");
            return resultOrderInfoAPIMsgBean;
        }

        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        //验证订单有效性
        MasterOrderInoExtend masterOrderInfoResult = masterOrderInfoService.selectBeanInoByPk(masterOrderSn);
        if (masterOrderInfoResult == null || masterOrderInfoResult.getOrderStatus() == 2) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单不存在或已经被取消！");
            return resultOrderInfoAPIMsgBean;
        }

        //如果有地址，直接返回
        String outContractPreviewUrl = masterOrderInfoResult.getOutContractPreviewUrl();
        if (StringUtils.isNotBlank(outContractPreviewUrl)) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("已经获取过地址[" + outContractPreviewUrl + "]，无需请求接口");
            contractInfoBean.setFilePath(outContractPreviewUrl);
            resultOrderInfoAPIMsgBean.setData(contractInfoBean);
            return resultOrderInfoAPIMsgBean;
        }

        FrameworkContractInfo contractInfo = null;

        //框架合同号
        String customerContractNum = masterOrderInfoResult.getCustomerContractNum();
        if (StringUtils.isNotBlank(customerContractNum)) {
            //查询框架合同信息(根据框架合同编号，状态为有效<已确认>，版本倒叙。查最后一条。)
            contractInfo = frameworkContractInfoService.selectOneByCommerceContractNoAndOrder(customerContractNum, "contract_ver DESC");
            if (contractInfo == null) {
                resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("框架合同信息不存在！");
                return resultOrderInfoAPIMsgBean;
            }
        }
        //先查询订单商品详情
        List<MasterOrderGoods> masterOrderGoods = masterOrderGoodsService.selectByMasterOrderSn(masterOrderInfoResult.getMasterOrderSn());
        if (masterOrderGoods == null || masterOrderGoods.size() == 0) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单商品不存在！");
            return resultOrderInfoAPIMsgBean;
        }
        List<ZgOrderDetail> orderDetails = new ArrayList<>();

        Set<String> goodsSnList = new HashSet<>();
        Set<String> depotCodeList = new HashSet<>();

        for (MasterOrderGoods masterOrderGood : masterOrderGoods) {
            goodsSnList.add(masterOrderGood.getGoodsSn());
            depotCodeList.add(masterOrderGood.getDepotCode());
        }

        Map<String, DepotInfoBean> depotInfoMap = new HashMap<>();
        // 仓库信息Map
        if (!CollectionUtils.isEmpty(depotCodeList)) {
            List<DepotInfoBean> depotInfoBeans = depotInfoBeanService.selectByDepotCodeList(new ArrayList<>(depotCodeList));
            if (depotInfoBeans != null && depotInfoBeans.size() > 0) {
                for (DepotInfoBean depotInfoBean : depotInfoBeans) {
                    depotInfoMap.put(depotInfoBean.getDepotCode(), depotInfoBean);
                }
            }
        }

        // 产品信息map
        Map<String, ProductSellerGoodsResult> productListMap = new HashMap<>();

//        ProductSellerGoodsParam productSellerGoodsParam = new ProductSellerGoodsParam();
//        productSellerGoodsParam.setProductSysCodeList(new ArrayList<>(goodsSnList));
        List<ProductSellerGoodsResult> productSellerGoodsResults = productSellerGoodsOtherService.selectByProductSysCodeList(new ArrayList<>(goodsSnList));
        if (productSellerGoodsResults != null && productSellerGoodsResults.size() > 0) {
            for (ProductSellerGoodsResult productSellerGoodsResult : productSellerGoodsResults) {
                productListMap.put(productSellerGoodsResult.getProductSysCode(), productSellerGoodsResult);
            }
        }

        //订单生成时间
        Date addTime = masterOrderInfoResult.getCreateTime();
        // 起点信息
        String beginLocNo = "";
        // 销售区域
        String salesArea = "";
        // 产品大类
        String prodClass = "";
        //尺寸讯息
        String sizeMsg = "";
        //商品厚度
        String productThick = "";
        for (MasterOrderGoods bean : masterOrderGoods) {
            // 兰格建立订单明细
            ZgOrderDetail zgOrderDetail = this.spellOrderDetail(bean);
            // 发货周期
            String shipReqDateStr;
            if (bean.getDeliveryCycle() > 0) {
                Date cycleDate = UtilDate.getTurnDate(addTime, bean.getDeliveryCycle());
                shipReqDateStr = UtilDate.getDateStr(cycleDate);
            } else {
                shipReqDateStr = UtilDate.getDateStr(bean.getExpectedShipTime());
            }
            zgOrderDetail.setShipReqDate(shipReqDateStr);
            //产品厚度
            productThick = bean.getProductThick().toEngineeringString();
            // 起点
            if (depotInfoMap != null && depotInfoMap.size() > 0 && StringUtils.isNotBlank(bean.getDepotCode()) && depotInfoMap.containsKey(bean.getDepotCode())) {
                DepotInfoBean depotInfoBean = depotInfoMap.get(bean.getDepotCode());
                beginLocNo = depotInfoBean.getStartCode();
                zgOrderDetail.setBeginLocNo(beginLocNo);
                String depotCode = depotInfoBean.getDepotCode();
                zgOrderDetail.setWarehouseNo(depotCode);
            }
            zgOrderDetail.setAreaNo(masterOrderInfoResult.getSaleAreaCode());
            // 产品信息
            if (StringUtils.isNotBlank(bean.getGoodsSn()) && 0 != productListMap.size() && productListMap.containsKey(bean.getGoodsSn())) {
                ProductSellerGoodsResult sellerGoods = productListMap.get(bean.getGoodsSn());
                // 产品规范编号
                zgOrderDetail.setPsrNo(sellerGoods.getPsrNo());
                // 产品型态
                zgOrderDetail.setProdType(sellerGoods.getProductTypeNo());
                // 用途码
               // zgOrderDetail.setApnNo(sellerGoods.getProductApnno());
                // 标准全名
                zgOrderDetail.setStandName(sellerGoods.getStandName());
                // 制造标准代码
                zgOrderDetail.setMscNo(sellerGoods.getMscNo());
                //产品信息
               // sizeMsg = sellerGoods.getProductSizeMsg();
                //产品大类
                prodClass = sellerGoods.getProdClass();
                zgOrderDetail.setProdClass(prodClass);

            }
            /*
            PRODTYPE=RRB || PRODTYPE=RRW || PRODTYPE=ZRP
            */
            if ("RRB".equals(zgOrderDetail.getProdType())
                    || "RRW".equals(zgOrderDetail.getProdType())
                    || "ZRP".equals(zgOrderDetail.getProdType())) {
                BigDecimal orderLengthMax = bean.getOrderLengthMax();
                zgOrderDetail.setOrderLengthMax(orderLengthMax == null ? zgOrderDetail.getOrderLength() : orderLengthMax.toEngineeringString());
                BigDecimal orderLengthMin = bean.getOrderLengthMin();
                zgOrderDetail.setOrderLengthMin(orderLengthMin == null ? zgOrderDetail.getOrderLength() : orderLengthMin.toEngineeringString());
            }
            orderDetails.add(zgOrderDetail);
        }

        // 销售员
        String bdUserName = "";
        // 客户公司编码
        String companyCode = "";
        // 排产方式
        String contractTypeB = "";

        bdUserName = masterOrderInfoResult.getStaffCode();
        salesArea = masterOrderInfoResult.getSaleAreaCode();
        companyCode = masterOrderInfoResult.getCompanyCode();
        //订单类型
        Integer orderType = masterOrderInfoResult.getOrderType();
        if (orderType == 0) {
            //现货订单
            contractTypeB = "I";
        }
        if (orderType == 7) {
            //生产订单
            contractTypeB = "P";
            //钢贸定制商品列表中 建材 排产方式：现货订单
            //2021年3月2日 17:08:30
            Map<String, Object> paraMap = new HashMap<>();
            paraMap.put("productFormCode", masterOrderInfoResult.getProductTypeNo());
            ProductLibCategory productLibCategory = productLibCategoryExtMapper.selectByExampleForProductFrom(paraMap);
            if (productLibCategory != null && productLibCategory.getParentId() == ZgMethodBeanUtil.STEELS_CATE_CODE_INT) {
                contractTypeB = "I";
            }
        }
        /*
        SO01-订单建立
        订单资料档建立
         */
        ZgOrderMainBean zgOrderMainBean = new ZgOrderMainBean();
        zgOrderMainBean.setInputcode(zgOrderParamBean.getInputCode());
        zgOrderMainBean.setOrderType(orderType);

        //编辑框架合同相关
        if (contractInfo != null) {
            this.framework(contractInfo, zgOrderMainBean, masterOrderInfoResult);
        }

        // 封装订单信息
        this.spellOrderMain(masterOrderInfoResult, zgOrderMainBean, new ArrayList<String>(depotCodeList));

        // 销售员
        if (StringUtils.isNotBlank(bdUserName)) {
            zgOrderMainBean.setSalesMan(bdUserName);
        }
        // 销售区域
        if (StringUtils.isNotBlank(salesArea)) {
            zgOrderMainBean.setSalesArea(salesArea);
        }
        // 客户编号
        if (StringUtils.isNotBlank(companyCode)) {
            zgOrderMainBean.setCustNo(companyCode);
        }
        // 排产方式
        if (StringUtils.isNotBlank(contractTypeB)) {
            zgOrderMainBean.setContractTypeB(contractTypeB);
        }
        zgOrderMainBean.setOrderType(orderType);
        //销售组
        zgOrderMainBean.setSalesGroup(masterOrderInfoResult.getSaleGroupCode());

        zgOrderMainBean.setProdClass(prodClass);
        zgOrderMainBean.setSizeMsg(sizeMsg);
        if (StringUtils.isNotBlank(productThick)) {
            zgOrderMainBean.setOrderThick(new BigDecimal(productThick));
        }
        // 排产方式(1现货订单,2生产订单)
        // 排产方式 P:生产订单 I:现货订单
//        String contractTypeB = "I";
//        if (toProductionScheduling == 2) {
//            contractTypeB = "P";
//        }
        zgOrderMainBean.setContractTypeB(contractTypeB);
        if (StringUtils.isBlank(zgOrderMainBean.getBeginLocNo())) {
            zgOrderMainBean.setBeginLocNo(beginLocNo);
        }
        // 填充订单详情信息
        if (!CollectionUtils.isEmpty(orderDetails)) {
            for (ZgOrderDetail itemBean : orderDetails) {
                itemBean.setDraftOrderNo(zgOrderMainBean.getDraftOrderNo());
                itemBean.setSiteKind(zgOrderMainBean.getSiteKind());
                itemBean.setCarKind(zgOrderMainBean.getCarKind());
                itemBean.setRecOrderNo(zgOrderMainBean.getRecOrderNo());
                if (StringUtils.isBlank(zgOrderMainBean.getBeginLocNo())) {
                    itemBean.setBeginLocNo(zgOrderMainBean.getBeginLocNo());
                }
                // 合同编号
                if (StringUtils.isBlank(zgOrderMainBean.getContractNo())) {
                    itemBean.setSpecialPriceFlag("Y");
                }
                itemBean.setEndLocNo(zgOrderMainBean.getEndLocNo());
                itemBean.setAreaNo(zgOrderMainBean.getAreaNo());
            }
        }

        String template;
        switch (zgOrderMainBean.getProdClass()) {
            case "B":
                template = "H";
                break;
            case "H":
                template = "A";
                break;
            case "R":
                template = "D";
                break;
            case "W":
                template = "B";
                break;
//            case "X":
//                template = "G";
//                break;
            case "Z":
                template = "E";
                break;
            default:
                log.warn("产品大类[{}]<可能>未找到与之匹配的合同模板", zgOrderMainBean.getProdClass());
                template = "G";
        }
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("FORMID", ZgMethodBeanUtil.SO01);
        paramsMap.put("MAIN", zgOrderMainBean);
        paramsMap.put("DETAILS", orderDetails);
        paramsMap.put("TEMPLATE", template);

        ZgCallServiceUtils zgCallServiceUtils = new ZgCallServiceUtils();
        //填充方法信息
        ZgCallWsdlAPIBaseDTO wsdlUtilBean = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        wsdlUtilBean.setUrl(ZG_SO_NEW_URL);
        //方法名
        wsdlUtilBean.setInterfaceName(EnumZgAPINames.ORDER_SHOW_PDF.getZgApiNameCode());
        //参数名称
        wsdlUtilBean.setParameterType(EnumZgAPINames.ORDER_SHOW_PDF.getZgApiNameSystemCode());
        //设置默认返回信息
        APIMsgBean<String> dataBean = zgCallServiceUtils.commonCallZgSoApi(ZgParamUtils.transToUpperObject(JSONObject.toJSON(paramsMap).toString()), wsdlUtilBean);
        String data = dataBean.getData();
        ZgResultBean zgResultBean = JSONObject.parseObject(data, ZgResultBean.class);

        String actionNote = "通知中冠合同预览失败";
        /*
        如果地址获取成功了。回写订单上的合同地址
         */
        if (null != zgResultBean && zgResultBean.isOk() && StringUtils.isNotBlank(zgResultBean.getFilePath())) {
            String filePath = zgResultBean.getFilePath();
            //回写合同号
            MasterOrderInfoExtend extend = new MasterOrderInfoExtend();
            extend.setMasterOrderSn(masterOrderSn);
            extend.setOutContractPreviewUrl(filePath);
            masterOrderInfoExtendService.updateByPrimaryKeySelective(extend);
            //配置返回值
            actionNote = "通知中冠合同预览成功,url：" + filePath;
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean(actionNote));
            contractInfoBean.setFilePath(filePath);
            resultOrderInfoAPIMsgBean.setData(contractInfoBean);
        } else if (null != zgResultBean && !zgResultBean.isOk() && StringUtils.isNotBlank(zgResultBean.getMsg().toString())) {
            actionNote = "通知中冠合同预览失败,原因：" + zgResultBean.getMsg().toString();
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(actionNote));
        } else {
            actionNote = "通知中冠合同预览失败";
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(actionNote));
        }
        return resultOrderInfoAPIMsgBean;
    }

    /**
     * SO01-订单建立
     *
     * @param zgOrderParamBean 订单号	orderNo
     * @return 合同编号    contractNo
     */
    @Override
    public APIMsgBean<ContractInfoBean> createPushOrder(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<ContractInfoBean> resultOrderInfoAPIMsgBean = new APIMsgBean<>();

        if (zgOrderParamBean == null || StringUtils.isBlank(zgOrderParamBean.getMasterOrderSn())) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("参数异常，订单号不能为空");
            return resultOrderInfoAPIMsgBean;
        }

        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        //验证订单有效性
        MasterOrderInoExtend masterOrderInfoResult = masterOrderInfoService.selectBeanInoByPk(masterOrderSn);
        if (masterOrderInfoResult == null || masterOrderInfoResult.getOrderStatus() == 2) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单不存在或已经被取消！");
            return resultOrderInfoAPIMsgBean;
        }
        FrameworkContractInfo contractInfo = null;
        //验证合同是否生成
        String contractSn = masterOrderInfoResult.getOutContractSn();
        if (StringUtils.isNotBlank(contractSn)) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("建立订单失败,原因：电商单号已生成合同号：" + contractSn);
            return resultOrderInfoAPIMsgBean;
        }

        //框架合同号
        String customerContractNum = masterOrderInfoResult.getCustomerContractNum();
        if (StringUtils.isNotBlank(customerContractNum)) {
            //查询框架合同信息(根据框架合同编号，状态为有效<已确认>，版本倒叙。查最后一条。)
            contractInfo = frameworkContractInfoService.selectOneByCommerceContractNoAndOrder(customerContractNum, "contract_ver DESC");
            if (contractInfo == null) {
                resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("框架合同信息不存在！");
                return resultOrderInfoAPIMsgBean;
            }
        }
//        // 排产方式(1现货订单,2生产订单)
//        int toProductionScheduling = 1;
        //先查询订单商品详情
        List<MasterOrderGoods> masterOrderGoods = masterOrderGoodsService.selectByMasterOrderSn(masterOrderInfoResult.getMasterOrderSn());
        if (masterOrderGoods == null || masterOrderGoods.size() == 0) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单商品不存在！");
            return resultOrderInfoAPIMsgBean;
        }
        List<ZgOrderDetail> orderDetails = new ArrayList<>();

        Set<String> goodsSnList = new HashSet<>();
        Set<String> depotCodeList = new HashSet<>();

        for (MasterOrderGoods masterOrderGood : masterOrderGoods) {
            goodsSnList.add(masterOrderGood.getGoodsSn());
            depotCodeList.add(masterOrderGood.getDepotCode());
            // Integer presaleType = bean.getPresaleType();
//            // 排产方式(1现货订单,2生产订单)
//            int productionScheduling = TypeUtil.getProductionScheduling(presaleType, resultMasterOrder.getGroupBuyId(), null);
//            if (productionScheduling == 2) {
//                toProductionScheduling = 2;
//            }
        }

        Map<String, DepotInfoBean> depotInfoMap = new HashMap<>();
        // 仓库信息Map
        if (!CollectionUtils.isEmpty(depotCodeList)) {
            List<DepotInfoBean> depotInfoBeans = depotInfoBeanService.selectByDepotCodeList(new ArrayList<>(depotCodeList));
            if (depotInfoBeans != null && depotInfoBeans.size() > 0) {
                for (DepotInfoBean depotInfoBean : depotInfoBeans) {
                    depotInfoMap.put(depotInfoBean.getDepotCode(), depotInfoBean);
                }
            }
        }

        // 产品信息map
        Map<String, ProductSellerGoodsResult> productListMap = new HashMap<>();

        List<ProductSellerGoodsResult> productSellerGoodsResults = productSellerGoodsOtherService.selectByProductSysCodeList(new ArrayList<>(goodsSnList));
        if (productSellerGoodsResults != null && productSellerGoodsResults.size() > 0) {
            for (ProductSellerGoodsResult productSellerGoodsResult : productSellerGoodsResults) {
                productListMap.put(productSellerGoodsResult.getProductSysCode(), productSellerGoodsResult);
            }
        }

        //订单生成时间
        Date addTime = masterOrderInfoResult.getCreateTime();
        // 起点信息
        String beginLocNo = "";
        // 销售区域
        String salesArea = "";
        // 产品大类
        String prodClass = "";
        //尺寸讯息
        String sizeMsg = "";
        //商品厚度
        String productThick = "";
        for (MasterOrderGoods bean : masterOrderGoods) {
            // 兰格建立订单明细
            ZgOrderDetail zgOrderDetail = this.spellOrderDetail(bean);
            // 发货周期
            String shipReqDateStr;
            if (bean.getDeliveryCycle() > 0) {
                Date cycleDate = UtilDate.getTurnDate(addTime, bean.getDeliveryCycle());
                shipReqDateStr = UtilDate.getDateStr(cycleDate);
            } else {
                shipReqDateStr = UtilDate.getDateStr(bean.getExpectedShipTime());
            }
            zgOrderDetail.setShipReqDate(shipReqDateStr);
            //产品厚度
            productThick = bean.getProductThick().toEngineeringString();
            // 起点
            if (depotInfoMap != null && depotInfoMap.size() > 0 && StringUtils.isNotBlank(bean.getDepotCode()) && depotInfoMap.containsKey(bean.getDepotCode())) {
                DepotInfoBean depotInfoBean = depotInfoMap.get(bean.getDepotCode());
                beginLocNo = depotInfoBean.getStartCode();
                zgOrderDetail.setBeginLocNo(beginLocNo);
                String depotCode = depotInfoBean.getDepotCode();
                zgOrderDetail.setWarehouseNo(depotCode);
            }
            zgOrderDetail.setAreaNo(masterOrderInfoResult.getSaleAreaCode());
            // 产品信息
            if (StringUtils.isNotBlank(bean.getGoodsSn()) && 0 != productListMap.size() && productListMap.containsKey(bean.getGoodsSn())) {
                ProductSellerGoodsResult sellerGoods = productListMap.get(bean.getGoodsSn());
                // 产品规范编号
                zgOrderDetail.setPsrNo(sellerGoods.getPsrNo());
                // 产品型态
                zgOrderDetail.setProdType(sellerGoods.getProductTypeNo());
                // 用途码
               // zgOrderDetail.setApnNo(sellerGoods.getProductApnno());
                // 标准全名
                zgOrderDetail.setStandName(sellerGoods.getStandName());
                // 制造标准代码
                zgOrderDetail.setMscNo(sellerGoods.getMscNo());
                //产品信息
                //sizeMsg = sellerGoods.getProductSizeMsg();
                //产品大类
                prodClass = sellerGoods.getProdClass();
                zgOrderDetail.setProdClass(prodClass);

            }
            /*
            PRODTYPE=RRB || PRODTYPE=RRW || PRODTYPE=ZRP
            */
            if ("RRB".equals(zgOrderDetail.getProdType())
                    || "RRW".equals(zgOrderDetail.getProdType())
                    || "ZRP".equals(zgOrderDetail.getProdType())) {
                BigDecimal orderLengthMax = bean.getOrderLengthMax();
                zgOrderDetail.setOrderLengthMax(orderLengthMax == null ? zgOrderDetail.getOrderLength() : orderLengthMax.toEngineeringString());
                BigDecimal orderLengthMin = bean.getOrderLengthMin();
                zgOrderDetail.setOrderLengthMin(orderLengthMin == null ? zgOrderDetail.getOrderLength() : orderLengthMin.toEngineeringString());
            }
            orderDetails.add(zgOrderDetail);
        }

        // 销售员
        String bdUserName = "";
        // 客户公司编码
        String companyCode = "";
        // 排产方式
        String contractTypeB = "";

        bdUserName = masterOrderInfoResult.getStaffCode();
        salesArea = masterOrderInfoResult.getSaleAreaCode();
        companyCode = masterOrderInfoResult.getCompanyCode();
        //订单类型
        Integer orderType = masterOrderInfoResult.getOrderType();
        if (orderType == 0) {
            //现货订单
            contractTypeB = "I";
        }
        if (orderType == 7) {
            //生产订单
            contractTypeB = "P";
            //钢贸定制商品列表中 建材 排产方式：现货订单
            //2021年3月2日 17:08:30
            Map<String, Object> paraMap = new HashMap<>();
            paraMap.put("productFormCode", masterOrderInfoResult.getProductTypeNo());
            ProductLibCategory productLibCategory = productLibCategoryExtMapper.selectByExampleForProductFrom(paraMap);
            if (productLibCategory != null && productLibCategory.getCategoryId() == ZgMethodBeanUtil.STEELS_CATE_CODE_INT) {
                contractTypeB = "I";
            }
        }
        /*
        SO01-订单建立
        订单资料档建立
         */
        ZgOrderMainBean zgOrderMainBean = new ZgOrderMainBean();
        zgOrderMainBean.setInputcode(zgOrderParamBean.getInputCode());
        zgOrderMainBean.setOrderType(orderType);

        //编辑框架合同相关
        if (contractInfo != null) {
            this.framework(contractInfo, zgOrderMainBean, masterOrderInfoResult);
        }

        // 封装订单信息
        this.spellOrderMain(masterOrderInfoResult, zgOrderMainBean, new ArrayList<String>(depotCodeList));

        // 销售员
        if (StringUtils.isNotBlank(bdUserName)) {
            zgOrderMainBean.setSalesMan(bdUserName);
        }
        // 销售区域
        if (StringUtils.isNotBlank(salesArea)) {
            zgOrderMainBean.setSalesArea(salesArea);
        }
        // 客户编号
        if (StringUtils.isNotBlank(companyCode)) {
            zgOrderMainBean.setCustNo(companyCode);
        }
        // 排产方式
        if (StringUtils.isNotBlank(contractTypeB)) {
            zgOrderMainBean.setContractTypeB(contractTypeB);
        }


        //销售组
        zgOrderMainBean.setSalesGroup(masterOrderInfoResult.getSaleGroupCode());

        zgOrderMainBean.setProdClass(prodClass);
        zgOrderMainBean.setSizeMsg(sizeMsg);
        if (StringUtils.isNotBlank(productThick)) {
            zgOrderMainBean.setOrderThick(new BigDecimal(productThick));
        }
//        // 排产方式(1现货订单,2生产订单)
//        // 排产方式 P:生产订单 I:现货订单
//        String contractTypeB = "I";
//        if (toProductionScheduling == 2) {
//            contractTypeB = "P";
//        }
        zgOrderMainBean.setContractTypeB(contractTypeB);
        if (StringUtils.isBlank(zgOrderMainBean.getBeginLocNo())) {
            zgOrderMainBean.setBeginLocNo(beginLocNo);
        }
        // 填充订单详情信息
        if (!CollectionUtils.isEmpty(orderDetails)) {
            for (ZgOrderDetail itemBean : orderDetails) {
                itemBean.setDraftOrderNo(zgOrderMainBean.getDraftOrderNo());
                itemBean.setSiteKind(zgOrderMainBean.getSiteKind());
                itemBean.setCarKind(zgOrderMainBean.getCarKind());
                itemBean.setRecOrderNo(zgOrderMainBean.getRecOrderNo());
                if (StringUtils.isBlank(zgOrderMainBean.getBeginLocNo())) {
                    itemBean.setBeginLocNo(zgOrderMainBean.getBeginLocNo());
                }
                // 合同编号
                if (StringUtils.isBlank(zgOrderMainBean.getContractNo())) {
                    itemBean.setSpecialPriceFlag("Y");
                }
                itemBean.setEndLocNo(zgOrderMainBean.getEndLocNo());
                itemBean.setAreaNo(zgOrderMainBean.getAreaNo());
            }
        }
        //{"FORMID ":" SO01", "MAIN":{"draftOrderNo":"1111", "custNo":"XXXX", …}, "DETAILS": [{"明细1":"111"},{"明细2":"222"},…], "FEEDBACK":{isSuccess:"Y",msg :订单编号}}
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("FORMID", ZgMethodBeanUtil.SO01);
        paramsMap.put("MAIN", zgOrderMainBean);
        paramsMap.put("DETAILS", orderDetails);
        ZgWsdlResponseBaseBean value = new ZgWsdlResponseBaseBean();
        value.setIsSuccess("Y");
        value.setMsg(zgOrderMainBean.getDraftOrderNo());
        paramsMap.put("FEEDBACK", value);

        /*
        开始调用
        */
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //接口名称
        zgCallWsdlAPIBaseDTO.setUrl(ZG_SO_URL);
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.SO01.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.SO01.getZgApiNameCode());
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSONObject.toJSON(paramsMap).toString());
        zgCallWsdlAPIBaseDTO.setParaKey(masterOrderSn);
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
        String data = stringAPIMsgBean.getData();
        ZgResultBean zgResultBean = JSONObject.parseObject(data, ZgResultBean.class);

        String actionNote = "通知中冠建立订单失败";

        /*
        如果订单推送成功了。回写订单上的外部订单号
         */
        if (null != zgResultBean && zgResultBean.isOk() && StringUtils.isNotBlank(zgResultBean.getOrderNo())) {
            String outContractSn = zgResultBean.getOrderNo();
            //回写合同号
            MasterOrderInfo recordBean = new MasterOrderInfo();
            recordBean.setMasterOrderSn(masterOrderSn);
            recordBean.setOutContractSn(outContractSn);
            recordBean.setContractStatus(1);
            masterOrderInfoService.updateByPrimaryKeySelective(recordBean);
            //配置返回值
            actionNote = "通知中冠建立订单成功：" + outContractSn;
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage(actionNote);
            resultOrderInfoAPIMsgBean.getSoaStateBean().setCode(1);
            ContractInfoBean contractInfoBean = new ContractInfoBean();
            contractInfoBean.setContractNo(outContractSn);
            resultOrderInfoAPIMsgBean.setData(contractInfoBean);
            //订单建立成功发送短信通知
            //是否开启同步中冠处获取余额值  开启将查询crm  同步本地   关闭将获取本商城余额值信息
            APIParamMallConfigBean apiParamMallConfigBean = new APIParamMallConfigBean();
            apiParamMallConfigBean.setConfigKey(BackstageConstants.PAY_CHECK_SMS_NOTIFICATION);
            apiParamMallConfigBean.setStatus(BackstageConstants.STATUS_OK);
            apiParamMallConfigBean.setSiteCode(masterOrderInfoResult.getSiteCode());
            APIMsgBean<APIResultMallConfigBean> apiMsg = commonPublicInfoService.gyfmallConfigInfoByPara(apiParamMallConfigBean);
            if (apiMsg != null && apiMsg.getData() != null && apiMsg.getSoaStateBean() != null && apiMsg.getSoaStateBean().getCode() == ResultCodeConstants.SUCCESS
                    && StringUtils.equalsIgnoreCase(apiMsg.getData().getConfigValue(), "true")) {
                String userMobile = masterOrderInfoResult.getUserMobile();
                if (StringUtils.isNotBlank(userMobile)) {
                    ParaSendSmsInfoBean apiParaSendSmsInfoBean = new ParaSendSmsInfoBean();
                    apiParaSendSmsInfoBean.setPhone(userMobile);
                    apiParaSendSmsInfoBean.setContent(masterOrderSn);
                    apiParaSendSmsInfoBean.setUserName(BackstageConstants.NAME);
                    apiParaSendSmsInfoBean.setNickName(BackstageConstants.NAME);
                    apiParaSendSmsInfoBean.setSourceType(BackstageConstants.TYEP);
                    apiParaSendSmsInfoBean.setSendType(BackstageConstants.TYEP);
                    apiParaSendSmsInfoBean.setTemplateCode(BackstageConstants.TAKE_EFFECT);
                    smsInfoBeanService.sendSms(apiParaSendSmsInfoBean);
                }
            }
            log.info("数据库短信配置" + JSONObject.toJSON(apiMsg));
        } else if (null != zgResultBean && !zgResultBean.isOk() && StringUtils.isNotBlank(zgResultBean.getMsg().toString())) {
            actionNote = "通知中冠建立订单失败,原因：" + zgResultBean.getMsg().toString();
        } else {
            actionNote = "通知中冠建立订单失败";
        }
        resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage(actionNote);

        return resultOrderInfoAPIMsgBean;
    }

    /**
     * 中冠订单订单确认
     *
     * @param zgOrderParamBean 参数说明
     * @return com.work.shop.cloud.out.bean.zg.ZgResultBean    返回类型
     * @Title: addZgOrderConfirm
     * @Description: (这里用一句话描述这个方法的作用)
     * @author yuchaohua
     * @date 2020/9/18 18:28
     */
    @Override
    public APIMsgBean<Boolean> addZgOrderConfirm(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<Boolean> apiMsgBean = new APIMsgBean<>();
        apiMsgBean.setData(false);

        if (null == zgOrderParamBean || StringUtils.isBlank(zgOrderParamBean.getMasterOrderSn())) {
            apiMsgBean.getSoaStateBean().setMessage("必传参数为空");
            return apiMsgBean;
        }
        //  查询订单是否存在
        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        ParaMasterOrderInfo paraMasterOrderInfo = new ParaMasterOrderInfo();
        paraMasterOrderInfo.setMasterOrderSn(masterOrderSn);
        MasterOrderInfo resultMasterOrder = masterOrderInfoService.selectMasterOrderInfoByPara(paraMasterOrderInfo);
        if (null == resultMasterOrder || resultMasterOrder.getOrderStatus() == 2
                || StringUtils.isBlank(resultMasterOrder.getMasterOrderSn())
                || resultMasterOrder.getPayStatus() != 2) {
            log.error("订单不存在或不合法 ：" + JSON.toJSONString(resultMasterOrder));
            apiMsgBean.getSoaStateBean().setMessage("订单不存在或不合法");
            return apiMsgBean;
        }
        String actionNote = "通知中冠订单确认成功";
        try {
            Map<String, Object> paramMap = new HashMap<>();

            paramMap.put("FORMID", EnumZgAPINames.SO03.getZgApiNameCode());
            // 电子商务合同号(商城订单号)
            paramMap.put("DRAFTORDERNO", masterOrderSn);
            // 产销订单编号
            paramMap.put("ORDERNO", resultMasterOrder.getOutContractSn());
            //填充方法信息
            ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
            //请求地址
            zgCallWsdlAPIBaseDTO.setUrl(ZG_SO_URL);
            //方法名
            zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.SO03.getZgApiNameCode());
            //参数名称
            zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.SO03.getZgApiNameSystemCode());
            zgCallWsdlAPIBaseDTO.setParaKey(masterOrderSn);
            JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSONObject.toJSON(paramMap).toString());
            APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
            // 订单推送中冠系统结果
            ZgResultBean zgResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), ZgResultBean.class);
            // 如果订单推送成功了。校验订单上的外部订单号
            if (null != zgResultBean && zgResultBean.getMsg() != null) {
                ZgResultOrderConfirmBean resultOrderConfirmBean = JSONObject.parseObject(zgResultBean.getMsg().toString(), ZgResultOrderConfirmBean.class);
                if (resultOrderConfirmBean != null && resultOrderConfirmBean.isOk()) {
                    apiMsgBean.setData(true);
                    apiMsgBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean(actionNote));
                } else {
                    actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn + "<br/>订单确认失败,原因：";
                    if (resultOrderConfirmBean != null && StringUtils.isNotBlank(resultOrderConfirmBean.getMsg())) {
                        actionNote += resultOrderConfirmBean.getMsg();
                    } else {
                        actionNote += zgResultBean.getMsg().toString();
                    }
                    actionNote += "</font>";
                }
            } else {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠【" + masterOrderSn + "】订单确认失败</font>";
            }
        } catch (Exception e) {
            log.error(apiMsgBean.getSoaStateBean().getMessage() + JSONObject.toJSONString(masterOrderSn), e);
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn
                    + "订单确认失败：" + e.getMessage() + "</font>";
        }
        apiMsgBean.getSoaStateBean().setMessage(actionNote);
        return apiMsgBean;
    }

    /**
     * 中冠订单取消确认
     *
     * @param zgOrderParamBean 参数说明
     * @return com.work.shop.cloud.out.bean.zg.ZgResultBean    返回类型
     * @Title: cannotZgOrder
     * @Description: (这里用一句话描述这个方法的作用)
     * @author yuchaohua
     * @date 2020/9/18 18:26
     */
    @Override
    public APIMsgBean<Boolean> cannotZgOrder(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<Boolean> apiMsgBean = new APIMsgBean<>();
        apiMsgBean.setData(false);
        if (StringUtils.isBlank(zgOrderParamBean.getMasterOrderSn())) {
            apiMsgBean.getSoaStateBean().setMessage("必传参数为空");
            return apiMsgBean;
        }
        //  查询订单是否存在
        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        ParaMasterOrderInfo paraMasterOrderInfo = new ParaMasterOrderInfo();
        paraMasterOrderInfo.setMasterOrderSn(masterOrderSn);
        MasterOrderInfo resultMasterOrder = masterOrderInfoService.selectMasterOrderInfoByPara(paraMasterOrderInfo);
        if (null == resultMasterOrder || resultMasterOrder.getOrderStatus() != 2 || StringUtils.isBlank(masterOrderSn)) {
            log.error("订单不存在或不合法 ：" + JSON.toJSONString(resultMasterOrder));
            apiMsgBean.getSoaStateBean().setMessage("订单不存在或不合法");
            return apiMsgBean;
        }
        String actionNote = zgOrderParamBean.getOperator() + "通知中冠订单取消成功";
        try {
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("COMPID", KEY_COMPID);
            // 产销订单编号
            paramMap.put("ORDERNO", resultMasterOrder.getOutContractSn());
            //填充方法信息
            ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
            //请求地址
            zgCallWsdlAPIBaseDTO.setUrl(ZG_SO_NEW_URL);
            //方法名
            zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.CANCEL_ORDER_CONFIRM.getZgApiNameCode());
            //参数名称
            zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.CANCEL_ORDER_CONFIRM.getZgApiNameSystemCode());
            zgCallWsdlAPIBaseDTO.setParaKey(masterOrderSn);
            JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramMap));
            APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
            // 订单推送中冠系统结果
            ZgResultBean zgResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), ZgResultBean.class);
            // 如果订单推送成功了。回写订单上的外部订单号
            if (null != zgResultBean && zgResultBean.isOk()) {
                apiMsgBean.setData(true);
                apiMsgBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean(actionNote));
                //回写合同号
                String outOrderSn = zgResultBean.getOrderNo();
                MasterOrderInfo recordBean = new MasterOrderInfo();
                recordBean.setMasterOrderSn(masterOrderSn);
                recordBean.setOutOrderSn(outOrderSn);
                recordBean.setContractStatus(2);
                masterOrderInfoService.updateByPrimaryKeySelective(recordBean);
            } else if (null != zgResultBean && !zgResultBean.isOk()) {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn
                        + "<br/>订单取消失败,原因：" + zgResultBean.getMsg() + "</font>";
            } else {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠【" + masterOrderSn + "】订单取消失败</font>";
            }
        } catch (Exception e) {
            apiMsgBean.getSoaStateBean().setMessage("中冠订单取消失败");
            log.error(apiMsgBean.getSoaStateBean().getMessage() + JSONObject.toJSONString(zgOrderParamBean), e);
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn
                    + "订单取消失败：" + e.getMessage() + "</font>";
        }
        apiMsgBean.getSoaStateBean().setMessage(actionNote);
        return apiMsgBean;
    }

//    /**
//     * 中冠订单删除
//     *
//     * @param zgOrderParamBean 调用参数  内含订单号
//     * @return
//     */
//    @Override
//    public APIMsgBean<Boolean> deleteZgOrder(ZgOrderParamBean zgOrderParamBean) {
//        APIMsgBean<Boolean> apiMsgBean = new APIMsgBean<>();
//        apiMsgBean.setData(false);
//        if (zgOrderParamBean == null || StringUtils.isBlank(zgOrderParamBean.getMasterOrderSn())) {
//            apiMsgBean.getSoaStateBean().setMessage("参数异常，订单号不能为空");
//            return apiMsgBean;
//        }
//        zgOrderParamBean.setInputCode("D");
//        APIMsgBean<ContractInfoBean> pushOrder = this.createPushOrder(zgOrderParamBean);
//        if (pushOrder.getSoaStateBean().getCode() == 1) {
//            apiMsgBean.setData(true);
//        }
//        return apiMsgBean;
//    }

    /**
     * 通过订单号与客户编号，查询结算结果
     *
     * @param zgOrderParamBean 订单合同号	orderNo
     *                         客户编号		custNO
     * @return 结算结果
     */
    @Override
    public APIMsgBean<SSKEC007Bean> SSKEC007(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<SSKEC007Bean> sskec007Result = new APIMsgBean<>();

        //  查询订单是否存在
        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        ParaMasterOrderInfo paraMasterOrderInfo = new ParaMasterOrderInfo();
        paraMasterOrderInfo.setMasterOrderSn(masterOrderSn);
        MasterOrderInfo resultMasterOrder = masterOrderInfoService.selectMasterOrderInfoByPara(paraMasterOrderInfo);
        if (null == resultMasterOrder || resultMasterOrder.getOrderStatus() == 2 || StringUtils.isBlank(masterOrderSn)) {
            log.error("订单不存在或不合法 ：" + JSON.toJSONString(resultMasterOrder));
            sskec007Result.getSoaStateBean().setMessage("订单不存在或不合法");
            return sskec007Result;
        }

        ZgCallServiceUtils zgCallServiceUtils = new ZgCallServiceUtils();
        //填充方法信息
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("ORDERNO", resultMasterOrder.getOutContractSn());
        paramMap.put("CUSTNO", zgOrderParamBean.getCustNo());
        //填充方法信息
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        zgCallWsdlAPIBaseDTO.setUrl(ZG_SA_URL);
        //方法名
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.SSKEC007.getZgApiNameCode());
        //参数名称
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.SSKEC007.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setParaKey(masterOrderSn);
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramMap));
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
        // 订单推送中冠系统结果
        APIMsgBean sskec007Bean = JSONObject.parseObject(stringAPIMsgBean.getData(), APIMsgBean.class);
        Serializable data = sskec007Bean.getData();
        if (data instanceof SSKEC007Bean) {
            sskec007Result.setData((SSKEC007Bean) data);
            sskec007Result.setSoaStateBean(sskec007Bean.getSoaStateBean());
        } else {
            sskec007Result.getSoaStateBean().setMessage("返回值获取异常");
        }
        return sskec007Result;
    }

    /**
     * 通过订单号获取应付单
     * 获取整理 AV05 进行展示。仅 返回 电商单 数据。
     *
     * @param zgOrderParamBean 拼接后的合同号-orderNos
     * @return AV05（应收凭证）的集合
     */
    @Override
    public APIMsgBean<AVSystemInterfaceResultBean> getCanInvoiceListByOrderNo(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<AVSystemInterfaceResultBean> getCanInvoiceListByOrderNoResult = new APIMsgBean<>();
        getCanInvoiceListByOrderNoResult.setData(new AVSystemInterfaceResultBean());
        getCanInvoiceListByOrderNoResult.getData().setV05List(null);
        getCanInvoiceListByOrderNoResult.getSoaStateBean().setCode(0);

        String orderNos = zgOrderParamBean.getOrderNos();
        if (StringUtils.isBlank(orderNos)) {
            getCanInvoiceListByOrderNoResult.getSoaStateBean().setMessage("必传参数[orderNos]为空");
            return getCanInvoiceListByOrderNoResult;
        }

//        List<String> orderNoList = Arrays.asList(zgOrderParamBean.getOrderNos().split(","));
//        for (int i = 0; i < orderNoList.size(); i++) {
//            String outContractNo = orderNoList.get(i);
//        }
//
//        //  查询订单是否存在
//        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
//        MasterOrderInfo resultMasterOrder = masterOrderInfoMapper.selectByPrimaryKey(masterOrderSn);
//        if (null == resultMasterOrder || resultMasterOrder.getOrderStatus() == 2 || StringUtils.isBlank(masterOrderSn)) {
//            log.error("订单不存在或不合法 ：" + JSON.toJSONString(resultMasterOrder));
//            getCanInvoiceListByOrderNoResult.getSoaStateBean().setMessage("订单不存在或不合法");
//            return getCanInvoiceListByOrderNoResult;
//        }
//
//        if (StringUtils.isBlank(resultMasterOrder.getOutContractSn())) {
//            getCanInvoiceListByOrderNoResult.getSoaStateBean().setMessage("合同号为空，无法获取应付单");
//            return getCanInvoiceListByOrderNoResult;
//        }

        String actionNote = "";
        try {
            Map<String, Object> paramsMap = new HashMap<>();
            paramsMap.put("ORDERNO", orderNos);

            //填充方法信息
            ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
            //请求地址
            zgCallWsdlAPIBaseDTO.setUrl(ZG_AV_URL);
            //参数名称
            zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.GET_CAN_INVOICE_LIST_BY_ORDER_NO.getZgApiNameCode());
            zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.GET_CAN_INVOICE_LIST_BY_ORDER_NO.getZgApiNameSystemCode());
            zgCallWsdlAPIBaseDTO.setParaKey(zgOrderParamBean.getInvoiceApplyOrderSn());
            JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
            APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
            // 订单推送中冠系统结果
            AVSystemInterfaceResultBean avSystemInterfaceResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), AVSystemInterfaceResultBean.class);

            if (null != avSystemInterfaceResultBean && Objects.equals(avSystemInterfaceResultBean.getIsSuccess(), "Y")) {
                getCanInvoiceListByOrderNoResult.getSoaStateBean().setCode(1);
                //写入数据
                getCanInvoiceListByOrderNoResult.getData().setV05List(avSystemInterfaceResultBean.getV05List());
                actionNote = "获取应付单成功！";
            } else if (null != avSystemInterfaceResultBean && StringUtils.isNotBlank(stringAPIMsgBean.getSoaStateBean().getMessage())) {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠订单号【" + orderNos
                        + "】<br/>获取应付单失败,原因：" + avSystemInterfaceResultBean.getMsg() + "</font>";
            } else {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠订单号【" + orderNos + "】获取应付单失败</font>";
            }
        } catch (Exception e) {
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠订单号【" + orderNos
                    + "】获取应付单失败：" + e.getMessage() + "</font>";
            log.error(actionNote + JSONObject.toJSONString(zgOrderParamBean), e);
        }
        getCanInvoiceListByOrderNoResult.getSoaStateBean().setMessage(actionNote);
        return getCanInvoiceListByOrderNoResult;
    }

    /**
     * 设置开明细票OR汇总票
     *
     * @param zgOrderParamBean 账套别		compId
     *                         应收凭单号	arNos
     *                         明细or汇总	detailOrSum		D为明细/S为汇总
     * @return v05返回应收凭证数组；V11返回开票申请主档数据；V12返回开票申请明细数据。
     */
    @Override
    public APIMsgBean<AVSystemInterfaceResultBean> setDetailOrSumData(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<AVSystemInterfaceResultBean> setDetailOrSumDataResult = new APIMsgBean<>();
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("COMPID", zgOrderParamBean.getCompId());
        paramsMap.put("ARNOS", zgOrderParamBean.getArNos());
        paramsMap.put("DETAILORSUM", zgOrderParamBean.getDetailOrSum());

        //填充方法信息
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        zgCallWsdlAPIBaseDTO.setUrl(ZG_AV_URL);
        //参数名称
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.SET_DETAIL_OR_SUM_DATA.getZgApiNameCode());
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.SET_DETAIL_OR_SUM_DATA.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setParaKey(zgOrderParamBean.getInvoiceApplyOrderSn());
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
        // 订单推送中冠系统结果
        AVSystemInterfaceResultBean avSystemInterfaceResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), AVSystemInterfaceResultBean.class);
        setDetailOrSumDataResult.setData(avSystemInterfaceResultBean);
        setDetailOrSumDataResult.getSoaStateBean().setMessage(avSystemInterfaceResultBean.getMsg());
        setDetailOrSumDataResult.getSoaStateBean().setCode(Objects.equals(avSystemInterfaceResultBean.getIsSuccess(), "Y") ? 1 : 0);
        return setDetailOrSumDataResult;
    }

    /**
     * 申请确认
     *
     * @param zgOrderParamBean 应收凭单号	ARNOQRY
     *                         账套别	COMPIDQRY
     *                         发票类型	MERGEQRY
     */
    @Override
    public APIMsgBean<AVSystemInterfaceResultBean> applyInvoiceOk(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<AVSystemInterfaceResultBean> applyInvoiceOkResult = new APIMsgBean<>();
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("ARNOQRY", zgOrderParamBean.getArNoQry());
        paramsMap.put("COMPIDQRY", zgOrderParamBean.getCompIdQry());
        paramsMap.put("MERGEQRY", zgOrderParamBean.getMergeQry());

        //填充方法信息
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        zgCallWsdlAPIBaseDTO.setUrl(ZG_AV_URL);
        //参数名称
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.APPLY_INVOICE_OK.getZgApiNameCode());
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.APPLY_INVOICE_OK.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setParaKey(zgOrderParamBean.getInvoiceApplyOrderSn());
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
        // 订单推送中冠系统结果
        AVSystemInterfaceResultBean avSystemInterfaceResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), AVSystemInterfaceResultBean.class);
        applyInvoiceOkResult.setData(avSystemInterfaceResultBean);
        applyInvoiceOkResult.getSoaStateBean().setMessage(avSystemInterfaceResultBean.getMsg());
        applyInvoiceOkResult.getSoaStateBean().setCode(Objects.equals(avSystemInterfaceResultBean.getIsSuccess(), "Y") ? 1 : 0);
        return applyInvoiceOkResult;
    }

    /**
     * 修改发票接收人资料
     *
     * @param zgOrderParamBean 应收凭单号		avNoQry
     *                         发票收件人姓名	receiverName
     *                         发票收件人电话	receiverPhone
     *                         发票收件人地址	sendAddr
     *                         发票类型			invoiceLimitAmtType
     *                         开票备注			memo
     */
    @Override
    public APIMsgBean<AVSystemInterfaceResultBean> custNoDataUpdate(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<AVSystemInterfaceResultBean> custNoDataUpdateResult = new APIMsgBean<>();
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("AVNOQRY", zgOrderParamBean.getAvNoQry());
        paramsMap.put("RECEIVERNAME", zgOrderParamBean.getReceiverName());
        paramsMap.put("RECEIVERPHONE", zgOrderParamBean.getReceiverPhone());
        paramsMap.put("SENDADDR", zgOrderParamBean.getSendAddr());
        paramsMap.put("INVOICELIMITAMTTYPE", zgOrderParamBean.getInvoiceLimitAmtType());
        paramsMap.put("MEMO", zgOrderParamBean.getMemo());

        //填充方法信息
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        zgCallWsdlAPIBaseDTO.setUrl(ZG_AV_URL);
        //参数名称
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.CUST_NO_DATA_UPDATE.getZgApiNameCode());
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.CUST_NO_DATA_UPDATE.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setParaKey(zgOrderParamBean.getMasterOrderSn());
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
        // 订单推送中冠系统结果
        AVSystemInterfaceResultBean avSystemInterfaceResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), AVSystemInterfaceResultBean.class);
        custNoDataUpdateResult.setData(avSystemInterfaceResultBean);
        custNoDataUpdateResult.getSoaStateBean().setMessage(avSystemInterfaceResultBean.getMsg());
        custNoDataUpdateResult.getSoaStateBean().setCode(Objects.equals(avSystemInterfaceResultBean.getIsSuccess(), "Y") ? 1 : 0);
        return custNoDataUpdateResult;
    }

    /**
     * 开票接口整合
     *
     * @param zgOrderParamBean 申请单号	invoiceApplyOrderSn
     */
    @Override
    public APIMsgBean<AVSystemInterfaceResultBean> issueInvoice(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<AVSystemInterfaceResultBean> resultMsgBean = new APIMsgBean<>();

        /*
        参数校验
         */
        String invoiceApplyOrderSn = zgOrderParamBean.getInvoiceApplyOrderSn();
        if (StringUtils.isBlank(invoiceApplyOrderSn)) {
            resultMsgBean.getSoaStateBean().setCode(0);
            resultMsgBean.getSoaStateBean().setMessage("必传参数申请单号[invoiceApplyOrderSn]为空");
            return resultMsgBean;
        }

        /*
        校验查询结果
         */
        List<MasterOrderInvoiceApplyDetail> detailList = masterOrderInvoiceApplyDetailService.selectByInvoiceApplyOrderSn(invoiceApplyOrderSn);
        if (CollectionUtils.isEmpty(detailList)) {
            resultMsgBean.getSoaStateBean().setCode(0);
            resultMsgBean.getSoaStateBean().setMessage("根据申请单号[" + invoiceApplyOrderSn + "]获取不到有效订单");
            return resultMsgBean;
        }
        List<String> masterOrderSnList = detailList.stream().map(MasterOrderInvoiceApplyDetail::getMasterOrderSn).collect(Collectors.toList());
        //无需校验订单状态
        //List<MasterOrderInfo> masterOrderInfoList = masterOrderInfoService.selectByMasterOrderSnList(masterOrderSnList);

        /*
        字符串拼接合同号
         */
        String orderNos = "";
        List<String> outOrderSnList = detailList.stream().map(MasterOrderInvoiceApplyDetail::getOutOrderSn).collect(Collectors.toList());
        StringBuilder stringBuilder = new StringBuilder();
        for (String outOrderSn : outOrderSnList) {
            stringBuilder.append(outOrderSn).append(",");
        }
        if (stringBuilder.length() > 0) {
            orderNos = stringBuilder.substring(0, stringBuilder.length() - 1);
        }

        zgOrderParamBean.setOrderNos(orderNos);
        APIMsgBean<AVSystemInterfaceResultBean> getCanInvoiceListByOrderNoResult = this.getCanInvoiceListByOrderNo(zgOrderParamBean);

        if (getCanInvoiceListByOrderNoResult.getSoaStateBean().getCode() == 0) {
            return getCanInvoiceListByOrderNoResult;
        }
        //账套别	compId
        String compId = "";
        //应收凭单号	arNos
        String arNos = "";
        StringBuilder sb = new StringBuilder();
        List<V05Bean> v05List = getCanInvoiceListByOrderNoResult.getData().getV05List();
        if (CollectionUtils.isEmpty(v05List)) {
            return getCanInvoiceListByOrderNoResult;
        }
        for (V05Bean v05Bean : v05List) {
            compId = v05Bean.getCompId();
            sb.append(v05Bean.getArNo()).append(",");
        }
        if (sb.length() > 0) {
            arNos = sb.substring(0, sb.length() - 1);
        }
        //拼装参数
        MasterOrderInvoiceApply masterOrderInvoiceApply = masterOrderInvoiceApplyService.selectOneByInvoiceApplyOrderSn(invoiceApplyOrderSn);
        if (masterOrderInvoiceApply == null) {
            resultMsgBean.getSoaStateBean().setCode(0);
            resultMsgBean.getSoaStateBean().setMessage("根据申请单号[\" + invoiceApplyOrderSn + \"]获取发票申请信息为空");
            return resultMsgBean;
        }
        if (StringUtils.isNotBlank(masterOrderInvoiceApply.getInvoiceDetailSum())) {
            //明细or汇总
            zgOrderParamBean.setDetailOrSum(masterOrderInvoiceApply.getInvoiceDetailSum());
        }
        zgOrderParamBean.setCompId(compId);
        zgOrderParamBean.setArNos(arNos);
        APIMsgBean<AVSystemInterfaceResultBean> setDetailOrSumDataResult = this.setDetailOrSumData(zgOrderParamBean);

        if (setDetailOrSumDataResult.getSoaStateBean().getCode() == 0) {
            return setDetailOrSumDataResult;
        }
        V11Bean v11 = setDetailOrSumDataResult.getData().getV11();
        if (v11 == null) {
            return setDetailOrSumDataResult;
        }
        zgOrderParamBean.setArNoQry(arNos);
        zgOrderParamBean.setCompIdQry(compId);
        zgOrderParamBean.setMergeQry(v11.getInvoiceType());
        APIMsgBean<AVSystemInterfaceResultBean> applyInvoiceOkResult = this.applyInvoiceOk(zgOrderParamBean);

        if (applyInvoiceOkResult.getSoaStateBean().getCode() == 0) {
            return applyInvoiceOkResult;
        }
        String avNoQry = applyInvoiceOkResult.getData().getAvNoQry();
//        MasterOrderInvoice masterOrderInvoice = masterOrderInvoiceMapper.selectByPrimaryKey(zgOrderParamBean.getOrderNo());
//        if (masterOrderInvoice == null) {
//            resultMsgBean.getSoaStateBean().setMessage("通过订单号获取发票信息失败");
//            return resultMsgBean;
//        }
        if (StringUtils.isBlank(avNoQry)) {
            return applyInvoiceOkResult;
        }
        //应收凭单号	avNoQry
        zgOrderParamBean.setAvNoQry(avNoQry);
        //发票收件人姓名	receiverName
        zgOrderParamBean.setReceiverName(masterOrderInvoiceApply.getReceiverName());
        //发票收件人电话	receiverPhone
        zgOrderParamBean.setReceiverPhone(masterOrderInvoiceApply.getReceiverPhone());
        //发票收件人地址	sendAddr
        zgOrderParamBean.setSendAddr(masterOrderInvoiceApply.getSendAddr());
        //发票类型	invoiceLimitAmtType
        zgOrderParamBean.setInvoiceLimitAmtType(masterOrderInvoiceApply.getInvoiceType());
        //开票备注	memo
        zgOrderParamBean.setMemo(masterOrderInvoiceApply.getRemarks());
        return this.custNoDataUpdate(zgOrderParamBean);
    }

    /**
     * AR03-查询运费余额
     *
     * @param zgOrderParamBean 客户编号	CUSTNO
     *                         运费担当	TRANSWAY
     * @return 运费余额    result
     */
    @Override
    public APIMsgBean<FreightBalanceBean> searchFreightBalance(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<FreightBalanceBean> searchFreightBalanceResult = new APIMsgBean<>();
        searchFreightBalanceResult.getSoaStateBean().setCode(0);

        if (zgOrderParamBean == null || StringUtils.isBlank(zgOrderParamBean.getCustNo()) || StringUtils.isBlank(zgOrderParamBean.getTransWay())) {
            searchFreightBalanceResult.getSoaStateBean().setMessage("参数异常，客户编号和运费担当不能为空");
            return searchFreightBalanceResult;
        }

        String transWay = zgOrderParamBean.getTransWay();
        List<String> transWayList = Arrays.asList("A", "D", "E", "H");
        if (transWayList.stream().noneMatch(tw -> tw.equalsIgnoreCase(transWay))) {
            searchFreightBalanceResult.getSoaStateBean().setMessage("参数异常，运费担当【" + transWay + "】不为\"A\"/\"D\"/\"E\"/\"H\"中的任意一个");
            return searchFreightBalanceResult;
        }

//        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
//        //验证订单有效性
//        MasterOrderInoExtend masterOrderInfoResult = masterOrderInfoMapper.selectBeanInoByPk(masterOrderSn);
//        if (masterOrderInfoResult == null || masterOrderInfoResult.getOrderStatus() == 2) {
//            searchFreightBalanceResult.getSoaStateBean().setMessage("订单不存在或已经被取消！");
//            return searchFreightBalanceResult;
//        }
//
//        MasterOrderInfo masterOrderInfo = masterOrderInfoMapper.selectByPrimaryKey(zgOrderParamBean.getMasterOrderSn());
//        String companyCode = masterOrderInfo.getCompanyCode();
//        String transWay;
//
//        Integer isCac = masterOrderInfo.getIsPickUp();
//        if (isCac != null && isCac == 1) {
//            transWay = "A";
//        } else {
//            // 结票方式(D:一票结、E:两票结)
//            transWay = masterOrderInfo.getSettlementTicket();
//        }
        String custNo = zgOrderParamBean.getCustNo();

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("FORMID", ZgMethodBeanUtil.AR03);
        paramsMap.put("CUSTNO", custNo);
        paramsMap.put("TRANSWAY", transWay);

        //填充方法信息
        ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
        //请求地址
        zgCallWsdlAPIBaseDTO.setUrl(ZG_AR_URL);
        //参数名称
        zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.AR03.getZgApiNameCode());
        zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.AR03.getZgApiNameSystemCode());
        zgCallWsdlAPIBaseDTO.setParaKey(zgOrderParamBean.getCustNo());
        JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
        APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);

        // 订单推送中冠系统结果
        FreightBalanceBean freightBalanceBean = JSONObject.parseObject(stringAPIMsgBean.getData(), FreightBalanceBean.class);

        String actionNote = "";

        if (null != freightBalanceBean && Objects.equals(freightBalanceBean.getIsSuccess(), "Y")) {
            searchFreightBalanceResult.getSoaStateBean().setCode(1);
            //写入数据
            searchFreightBalanceResult.setData(freightBalanceBean);
            actionNote = "获取运费余额成功：" + freightBalanceBean.getResult();
        } else if (null != freightBalanceBean && StringUtils.isNotBlank(stringAPIMsgBean.getSoaStateBean().getMessage())) {
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠客户编号【" + custNo
                    + "】<br/>获取运费余额失败,原因：" + stringAPIMsgBean.getSoaStateBean().getMessage() + "</font>";
        } else {
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠客户编号【" + custNo + "】获取运费余额失败</font>";
        }
        searchFreightBalanceResult.getSoaStateBean().setMessage(actionNote);
        return searchFreightBalanceResult;
    }

    /**
     * SO12-打印订单合同模板
     * 信息代号	SO12-打印订单合同模板
     * 信息说明	打印订单合同模板时
     * 传送方向	电子商务←→产销系统
     * 传送方式	webservice
     * 传送时机	打印订单合同模板时
     *
     * @param zgOrderParamBean 调用参数 内含订单合同号
     * @return
     */
    @Override
    public APIMsgBean<ContractAddressBean> saveContractAddress(ZgOrderParamBean zgOrderParamBean) {
        APIMsgBean<ContractAddressBean> resultOrderInfoAPIMsgBean = new APIMsgBean<>();
        ContractAddressBean returnBean = new ContractAddressBean();
        String masterOrderSn = zgOrderParamBean.getMasterOrderSn();
        if (StringUtils.isBlank(masterOrderSn)) {
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(ResultCodeConstants.FAIL_PARAM_MSG));
            return resultOrderInfoAPIMsgBean;
        }

        //  查询订单是否存在
        MasterOrderInoExtend resultMasterOrder = masterOrderInfoService.selectBeanInoByPk(masterOrderSn);
        if (null == resultMasterOrder || resultMasterOrder.getOrderStatus() == 2 || StringUtils.isBlank(masterOrderSn)) {
            log.error("订单不存在或不合法 ：" + JSON.toJSONString(resultMasterOrder));
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean("订单不存在或不合法"));
            return resultOrderInfoAPIMsgBean;
        }
        // 如果已经有了合同地址，不再继续找中冠获取
        if (StringUtils.isNotBlank(resultMasterOrder.getOutContractUrl())) {
            returnBean.setContractAddress(resultMasterOrder.getOutContractUrl());
            resultOrderInfoAPIMsgBean.setData(returnBean);
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean());
            return resultOrderInfoAPIMsgBean;
        }

        List<MasterOrderGoods> masterOrderGoods = masterOrderGoodsService.selectByMasterOrderSn(masterOrderSn);
        if (masterOrderGoods == null || masterOrderGoods.size() == 0) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单商品不存在！");
            return resultOrderInfoAPIMsgBean;
        }

        String prodClass = productSellerGoodsOtherService.selectProductClassByGoodSn(masterOrderGoods.get(0).getGoodsSn());
        if (StringUtils.isBlank(prodClass)) {
            resultOrderInfoAPIMsgBean.getSoaStateBean().setMessage("订单商品不合法，请检查订单商品类型！");
            return resultOrderInfoAPIMsgBean;
        }
        String template;
        switch (prodClass) {
            case "B":
                template = "H";
                break;
            case "H":
                template = "A";
                break;
//            case "P":
//                template = "";
//                break;
            case "R":
                template = "D";
                break;
            case "W":
                template = "B";
                break;
//            case "X":
//                template = "G";
//                break;
            case "Z":
                template = "E";
                break;
            default:
                log.warn("产品大类[{}]<可能>未找到与之匹配的合同模板", prodClass);
                template = "G";
        }

        String actionNote = "";
        try {
            Map<String, Object> paramsMap = new HashMap<>();
            paramsMap.put("FORMID", ZgMethodBeanUtil.SO12);
            paramsMap.put("ORDERNO", resultMasterOrder.getOutContractSn());
            paramsMap.put("TEMPLATE", template);

            //填充方法信息
            ZgCallWsdlAPIBaseDTO zgCallWsdlAPIBaseDTO = new ZgCallWsdlAPIBaseDTO();
            //请求地址
            zgCallWsdlAPIBaseDTO.setUrl(ZG_SO_URL);
            //参数名称
            zgCallWsdlAPIBaseDTO.setInterfaceName(EnumZgAPINames.SO12.getZgApiNameCode());
            zgCallWsdlAPIBaseDTO.setParameterType(EnumZgAPINames.SO12.getZgApiNameSystemCode());
            zgCallWsdlAPIBaseDTO.setParaKey(masterOrderSn);
            JSONObject jsonObject = ZgParamUtils.transToUpperObject(JSON.toJSONString(paramsMap));
            APIMsgBean<String> stringAPIMsgBean = zgCallServiceUtils.commonCallZgSoApi(jsonObject, zgCallWsdlAPIBaseDTO);
            // 订单推送中冠系统结果
            ZgResultBean zgResultBean = JSONObject.parseObject(stringAPIMsgBean.getData(), ZgResultBean.class);
            if (null != zgResultBean && zgResultBean.isOk()) {
                // 写入数据
                returnBean.setContractAddress(zgResultBean.getMsg().toString());
                resultOrderInfoAPIMsgBean.setData(returnBean);
                // 回写合地址
                MasterOrderInfoExtend extend = new MasterOrderInfoExtend();
                extend.setMasterOrderSn(masterOrderSn);
                extend.setOutContractUrl(zgResultBean.getMsg().toString());
                masterOrderInfoExtendService.updateByPrimaryKeySelective(extend);
            } else if (null != zgResultBean && !zgResultBean.isOk() && StringUtils.isNotBlank(resultOrderInfoAPIMsgBean.getSoaStateBean().getMessage())) {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn
                        + "<br/>打印订单合同模板失败,原因：" + resultOrderInfoAPIMsgBean.getSoaStateBean().getMessage() + "</font>";
            } else {
                actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠【" + masterOrderSn + "】打印订单合同模板失败</font>";
            }
        } catch (Exception e) {
            actionNote = "<font color=\"red\">" + zgOrderParamBean.getOperator() + "通知中冠" + masterOrderSn
                    + "打印订单合同模板失败：" + e.getMessage() + "</font>";
            log.error(actionNote + JSONObject.toJSONString(zgOrderParamBean), e);
        }
        if (StringUtils.isNotBlank(actionNote)) {
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(actionNote));
        } else {
            resultOrderInfoAPIMsgBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean());
        }
        return resultOrderInfoAPIMsgBean;
    }

    /**
     * 框架合同相关
     */
    private void framework(FrameworkContractInfo contractInfo, ZgOrderMainBean zgOrderMainBean, MasterOrderInoExtend masterOrderInfoResult) {
        //查询框架合同地址
        FrameworkContractAddressInfo frameworkContractAddressInfo = frameworkContractAddressInfoService.selectByPrimaryKey(contractInfo.getCommerceContractNo());

        //查询框架合同价格
        FrameworkContractPriceInfo frameworkContractPriceInfo = frameworkContractPriceInfoService.selectByPrimaryKey(contractInfo.getCommerceContractNo());

        //查询框架合同支付信息
        List<FrameworkContractPayInfo> frameworkContractPayInfos = frameworkContractPayInfoService.selectIgnoreCommerceContract(contractInfo.getCommerceContractNo());

        // 封装合同框架信息
        this.spellContractInfoOrderMain(contractInfo, zgOrderMainBean, frameworkContractAddressInfo, frameworkContractPriceInfo, frameworkContractPayInfos);
    }


    /**
     * 组装订单详情
     *
     * @param masterGoods 订单详情详情数据
     * @return
     * @author yaokan
     * @date 2020-11-26 上午9:44
     */
    private ZgOrderDetail spellOrderDetail(MasterOrderGoods masterGoods) {
        ZgOrderDetail orderDetail = new ZgOrderDetail();
        if (masterGoods != null) {
            // 计重方式 A:理论重; W:检斤重
            orderDetail.setCountWgtMode(masterGoods.getCountWgtMode());
            orderDetail.setDraftOrderItem(masterGoods.getC2mItem());
            // 单件重量
            orderDetail.setPieceWgt(masterGoods.getProductWgt().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
            // 订购数量
            orderDetail.setOrderQty(masterGoods.getGoodsQty() + "");
            // 订购重量 必填，单位吨
            BigDecimal pieceWeight = masterGoods.getProductWgt().multiply(BigDecimal.valueOf(masterGoods.getGoodsQty().intValue()));
            orderDetail.setOrderWgt(pieceWeight.setScale(4, BigDecimal.ROUND_HALF_UP).toString());
            // 货价  成交单价 * 重量
            orderDetail.setProdPrice(masterGoods.getGoodsPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
            // 牌号（材质）
            orderDetail.setTradeNo(masterGoods.getProductTradeno());
            //  运费单价
            BigDecimal shippingFee = masterGoods.getProductWgt().multiply(BigDecimal.valueOf(masterGoods.getShippingFee().doubleValue()));
            orderDetail.setFreightPrice(shippingFee.setScale(6, BigDecimal.ROUND_HALF_UP).toString());

            orderDetail.setPerformanceFlag(masterGoods.getPerformanceFlag());
            orderDetail.setCutEdgeCode(masterGoods.getCutedgeCode());
            orderDetail.setSizeMsg(masterGoods.getProductSizeMsg());
            orderDetail.setOrderThick(masterGoods.getProductThick().toEngineeringString());
            orderDetail.setOrderWidth(masterGoods.getProductWidth().toEngineeringString());
            orderDetail.setOrderLength(masterGoods.getProductLen().toEngineeringString());
            Map<String, String> attrValueAllMap = new HashMap<>();
        }
        return orderDetail;
    }

    /**
     * /* 封装合同框架信息
     * /*
     * /* @param contractInfo
     * /* @param orderMain
     */
    private void spellContractInfoOrderMain(FrameworkContractInfo contractInfo, ZgOrderMainBean zgOrderMainBean,
                                            FrameworkContractAddressInfo frameworkContractAddressInfo,
                                            FrameworkContractPriceInfo frameworkContractPriceInfo,
                                            List<FrameworkContractPayInfo> frameworkContractPayInfos) {
        if (null == contractInfo || null == zgOrderMainBean) {
            return;
        }
//        zgOrderMainBean.setProductionScheduling("P".equalsIgnoreCase(contractInfo.getProductionScheduling()) ? 1 : 2);
        zgOrderMainBean.setPriceMethod(contractInfo.getPriceMethod());
        zgOrderMainBean.setSupplyType(contractInfo.getSupplyType());
        zgOrderMainBean.setPayMethod(contractInfo.getPayMethod());
        if (StringUtils.isNotBlank(contractInfo.getPayMethod())) {
            zgOrderMainBean.setReceivePaymentMethod(contractInfo.getPayMethod());
        }
        //现款
        zgOrderMainBean.setCash(contractInfo.getCash().toString());

        zgOrderMainBean.setContractTypeA(contractInfo.getContractType());
        zgOrderMainBean.setContractTypeB(contractInfo.getProductionScheduling());
        zgOrderMainBean.setContractTypeC(contractInfo.getOrderType());
        if (zgOrderMainBean.getContractTypeC().equalsIgnoreCase("P")) {
            zgOrderMainBean.setContractTypeD(contractInfo.getPriceMethod());
        }
        zgOrderMainBean.setContractTypeE(contractInfo.getSupplyType());

        zgOrderMainBean.setSalesMan(contractInfo.getBdId());
        zgOrderMainBean.setAreaNo(contractInfo.getSaleAreaName());
        zgOrderMainBean.setSignedComp(contractInfo.getSaleCompanyId());
        // 交运资料
        if (frameworkContractAddressInfo != null) {
            this.spellContractInfoOrderMainAddress(frameworkContractAddressInfo, zgOrderMainBean);
        }

        //结算资料
        if (frameworkContractPriceInfo != null) {
            spellContractInfoOrderMainPrice(frameworkContractPriceInfo, zgOrderMainBean, frameworkContractPayInfos);
        }
        // 合同号
        zgOrderMainBean.setContractNo(contractInfo.getContractNo());
    }

    /**
     * 封装交运资料
     *
     * @param addressInfo
     * @param
     */
    private void spellContractInfoOrderMainAddress(FrameworkContractAddressInfo addressInfo, ZgOrderMainBean zgOrderMainBean) {
        if (null == addressInfo || null == zgOrderMainBean) {
            return;
        }
        // 运费担当
        zgOrderMainBean.setTransWay(addressInfo.getSettlementTicket());
        //  质保书寄送序号，必填
        zgOrderMainBean.setCertifyPostNo(addressInfo.getQualityAddressNo());
        // 质保书份数，必填
        zgOrderMainBean.setMillCopy(addressInfo.getQualityCount().toString());
        // 发票寄送序号，必填
        zgOrderMainBean.setInvPostNo(addressInfo.getInvoiceAddressNo());
//        // 收货人序号
//        zgOrderMainBean.setRecOrderNo(addressInfo.getAddressNo());
//        // 起点代码
//        zgOrderMainBean.setBeginLocNo(addressInfo.getStartNo());
//        // 终点代码，必填
//        zgOrderMainBean.setEndLocNo(addressInfo.getEndArea());
//        //终到地区，必填
//        zgOrderMainBean.setAreaNo(addressInfo.getEndArea());
//        //终点类型，必填
//        zgOrderMainBean.setSiteKind(addressInfo.getAddressType());
//        //载重类型，必填，默认『2』标载
//        zgOrderMainBean.setLoadWgtKind(addressInfo.getLoadingMode());
    }

    /**
     * 封装结算资料
     *
     * @param priceInfo
     */
    private void spellContractInfoOrderMainPrice(FrameworkContractPriceInfo priceInfo, ZgOrderMainBean zgOrderMainBean, List<FrameworkContractPayInfo> payInfoList) {
        if (null == priceInfo || null == zgOrderMainBean) {
            return;
        }
        //结算模式，必填
        if (ZgConstants.settleModeMap.containsKey(priceInfo.getSettlementMode())) {
            zgOrderMainBean.setSettleMode(ZgConstants.settleModeMap.get(priceInfo.getSettlementMode()));
        }
        // 结算周期起
        if (priceInfo.getSettlementDateBegin() != null) {
            zgOrderMainBean.setSettleDateS(UtilDate.date2String(priceInfo.getSettlementDateBegin(), "yyMMdd"));
        }
        // 结算周期迄
        if (priceInfo.getSettlementDateEnd() != null) {
            zgOrderMainBean.setSettleDateF(UtilDate.date2String(priceInfo.getSettlementDateEnd(), "yyMMdd"));
        }
        //定价区域 ，必填
        zgOrderMainBean.setDeliveryArea(priceInfo.getPriceSaleArea());
        // 缴款方式  必填
        zgOrderMainBean.setPaymentMethod("F");
        //结算资料缴款信息
        if (!CollectionUtils.isEmpty(payInfoList)) {
            //拼接结算资料缴款信息，只取前四次缴款信息
            //第一次缴款信息
            if (payInfoList.size() > 0) {
                FrameworkContractPayInfo bean = payInfoList.get(0);
                zgOrderMainBean.setPayDateA(UtilDate.date2String(bean.getPriceDate(), UtilDate.dtShort));
                zgOrderMainBean.setPayAmtA(bean.getPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                zgOrderMainBean.setPayMethodA(bean.getPriceType());
            }
            //第二次缴款信息
            if (payInfoList.size() > 1) {
                FrameworkContractPayInfo bean = payInfoList.get(1);
                zgOrderMainBean.setPayDateB(UtilDate.date2String(bean.getPriceDate(), UtilDate.dtShort));
                zgOrderMainBean.setPayAmtB(bean.getPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                zgOrderMainBean.setPayMethodB(bean.getPriceType());
            }
            //第三次缴款信息
            if (payInfoList.size() > 2) {
                FrameworkContractPayInfo bean = payInfoList.get(2);
                zgOrderMainBean.setPayDateC(UtilDate.date2String(bean.getPriceDate(), UtilDate.dtShort));
                zgOrderMainBean.setPayAmtC(bean.getPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                zgOrderMainBean.setPayMethodC(bean.getPriceType());
            }
            //第四次缴款信息
            if (payInfoList.size() > 3) {
                FrameworkContractPayInfo bean = payInfoList.get(3);
                zgOrderMainBean.setPayDateD(UtilDate.date2String(bean.getPriceDate(), UtilDate.dtShort));
                zgOrderMainBean.setPayAmtD(bean.getPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
                zgOrderMainBean.setPayMethodD(bean.getPriceType());
            }
        }
        // 缴款方式
        if (!CollectionUtils.isEmpty(payInfoList) && payInfoList.size() == 1) {
            zgOrderMainBean.setPaymentMethod("F");
        }
        //价格类别，必填
        if (StringUtils.isNotBlank(priceInfo.getPriceType())) {
            zgOrderMainBean.setPriceType(priceInfo.getPriceType());
        }
        //让利
        zgOrderMainBean.setCutPrice(priceInfo.getDiscountPrice());
        //打款优惠
        zgOrderMainBean.setPaymentFavourable(priceInfo.getPayDiscount());
        //运补
        zgOrderMainBean.setFreightFavourable(priceInfo.getFreightPay());
        //结算条款
        zgOrderMainBean.setSettleTerm(null);
        //网价群组
        zgOrderMainBean.setNetPriceGroup(priceInfo.getNetPriceType());
        //让利(指导价)
        zgOrderMainBean.setCutPrice2(priceInfo.getDiscountPrice());
        //指导价比例
        zgOrderMainBean.setGuidePriceRate(null);
        //扣减实际运费
        zgOrderMainBean.setSubActFreightPrice(priceInfo.getFreightSubstractType());
        //抓取合同价格，预设带『N』:否
        zgOrderMainBean.setPriceFromContract("N");
        //当月返利
        zgOrderMainBean.setRebateThisMonth(null);
        //最低几天定价
        zgOrderMainBean.setMinPriceDays(null);
        //结算日期型态，必填
        zgOrderMainBean.setSettleDateType(priceInfo.getSettlementDateType());
        //结算定价规则，预设带『A』:平均
        zgOrderMainBean.setSettleModeCountMode("A");
        //定价标准，必填
        zgOrderMainBean.setNetPriceCountMode(priceInfo.getPriceTypeStandard());
        //出厂第几天定价
        zgOrderMainBean.setOutFactoryDays(null);
        //周六日取价模式，必填
        zgOrderMainBean.setNonWorkDateGetPriceMode(priceInfo.getWeekendPriceRule());
        //取备注网价
        zgOrderMainBean.setIsNotePrice(priceInfo.getNetPriceRule());
        //法定假日取价模式
        zgOrderMainBean.setHolidayGetPriceMode(priceInfo.getHolidayPriceRule());
        // 结算条款
        zgOrderMainBean.setSettleTerm(priceInfo.getSettleTerm());
    }

    /**
     * 封装订单信息
     *
     * @param masterOrderInfo
     */
    private void spellOrderMain(MasterOrderInoExtend masterOrderInfo, ZgOrderMainBean zgOrderMainBean, List<String> depotCodeList) {
        if (null == masterOrderInfo || null == zgOrderMainBean) {
            return;
        }
        String masterOrderSn = masterOrderInfo.getMasterOrderSn();
        if (zgOrderMainBean.getInputcode() == null) {
            zgOrderMainBean.setInputcode("N");
        }
        zgOrderMainBean.setDraftOrderNo(masterOrderSn);
        zgOrderMainBean.setCustNo(masterOrderInfo.getUserName());
        zgOrderMainBean.setSalesCustNo(masterOrderInfo.getPalletMerchant());
//        zgOrderMainBean.setProdClass("B");
        if (StringUtils.isNotBlank(masterOrderInfo.getStaffCode())) {
            zgOrderMainBean.setSalesMan(masterOrderInfo.getStaffCode());
        }
        zgOrderMainBean.setContractTypeA("C");

        zgOrderMainBean.setSignedComp(masterOrderInfo.getSalesBranchCode());
        // 销售区域
        zgOrderMainBean.setSalesArea(masterOrderInfo.getSaleAreaCode());
        zgOrderMainBean.setReceivePaymentMethod(zgOrderMainBean.getReceivePaymentMethod());
        // 定价区域
        zgOrderMainBean.setDeliveryArea(masterOrderInfo.getPriceAreaCode());

        String transWay;
        // 是否自提 0 配送 1 是自提
        Integer isCac = masterOrderInfo.getIsPickUp();
        if (isCac != null && isCac == 1) {
            transWay = "A";
        } else {
            // 结票方式(D:一票结、E:两票结)
            transWay = masterOrderInfo.getSettlementTicket();
        }
        zgOrderMainBean.setTransWay(transWay);

        //查询收货地址信息
        MasterOrderAddressInfo resultAddress = masterOrderAddressInfoService.selectByPrimaryKey(masterOrderInfo.getMasterOrderSn());
        if (resultAddress != null) {
            zgOrderMainBean.setRecOrderNo(resultAddress.getZgRecOrderNo());
            zgOrderMainBean.setCertifyPostNo(resultAddress.getZgRecOrderNo());
            zgOrderMainBean.setInvPostNo(resultAddress.getZgRecOrderNo());
            zgOrderMainBean.setAreaNo(resultAddress.getFinishAreaCode());
            zgOrderMainBean.setEndLocNo(resultAddress.getLocaleCode());
            zgOrderMainBean.setBeginLocNo(resultAddress.getStartAreaCode());

            // 载重类型
            zgOrderMainBean.setLoadWgtKind(resultAddress.getLoadingMode() + "");
            // 终点类型
            zgOrderMainBean.setSiteKind(resultAddress.getAddressType());
            // 车辆要求(0无要求1高箱2低箱)
            zgOrderMainBean.setCarKind(resultAddress.getCarType() + "");
            // 运输方式 T 汽运  R 火运
            zgOrderMainBean.setTransWayNo(resultAddress.getCartCode());
        }
        // 判断订单是否已经支付
//        if (masterOrderInfo.getPayStatus() == 2){
        zgOrderMainBean.setPayDateA(UtilDate.date2String(masterOrderInfo.getConfirmTime(), UtilDate.dtShort));
        zgOrderMainBean.setPayAmtA(PriceUtils.round(masterOrderInfo.getTotalFee().doubleValue(), 4) + "");
        zgOrderMainBean.setPayMethodA("");
        zgOrderMainBean.setCash(PriceUtils.round(masterOrderInfo.getTotalFee().doubleValue(), 4) + "");
//        }
    }

    /**
     * 获取质保书信息
     *
     * @return com.steel.yfmall.cloud.components.utils.base.APIMsgBean<com.steel.yfmall.cloud.components.utils.base.Pages < com.steel.yfmall.cloud.assistant.bean.result.APIResultWarrantyBean>>    返回类型
     * @Title: getWarrantyFromZg
     * @Description: (这里用一句话描述这个方法的作用)
     * @Param apiParaBean 参数说明
     * @author yuchaohua
     * @date 2021/2/20 15:05
     */
    @Override
    public APIMsgBean<Pages<APIResultWarrantyBean>> getWarrantyFromZg(APIParaWarrantyBean apiParaBean) {
        if (apiParaBean == null) {
            apiParaBean = new APIParaWarrantyBean();
        }
        //品名
        if (StringUtils.isNotBlank(apiParaBean.getCategoryName())) {

        }
        // 客户名称
        if (StringUtils.isNotBlank(apiParaBean.getCustomerName())) {
            ParaUserCompanyBean paraCompanyBean = new ParaUserCompanyBean();
            paraCompanyBean.setCompanyNameLike(apiParaBean.getCustomerName());
            List<UserCompany> userCompanyList = userCompanyService.getUserCompanyListByPara(paraCompanyBean);
            if (org.apache.commons.collections.CollectionUtils.isNotEmpty(userCompanyList)) {
                String customerNoList = "";
                for (UserCompany item : userCompanyList) {
                    if (StringUtils.isNotBlank(customerNoList)) {
                        customerNoList += ",";
                    }
                    customerNoList += item.getCompanyCode();
                }
                apiParaBean.setCustomerNoList(customerNoList);
            }
        }

        return warrantyService.getWarrantyFromZg(apiParaBean);
    }


    /**
     * soWS01 接口地址配置
     */
    @Value("${jyjt_zgSystem_soWS01_url}")
    private String ZG_SO_URL;

    /**
     * soWSKEC 接口地址配置
     */
    @Value("${jyjt_zgSystem_soWSKEC_url}")
    private String ZG_SO_NEW_URL;

    /**
     * avWS01 接口地址配置
     */
    @Value("${jyjt_zgSystem_avWS01_URL}")
    private String ZG_AV_URL;

    /**
     * saWS01 接口地址配置
     */
    @Value("${jyjt_zgSystem_saWS01_url}")
    private String ZG_SA_URL;

    /**
     * arjiWebSrv 接口地址配置
     */
    @Value("${jyjt_zgSystem_arjiWebSrv_url}")
    private String ZG_AR_URL;

    /**
     * 订单取消确定COMPID的固定默认值
     */
    public final String KEY_COMPID = "hbjyjt";

    /**
     * 合同预览时 TEMPLATE 取值
     */
    public final String TEMPLATE_PRE_SHOW = "B";

    @Resource
    private MasterOrderInfoService masterOrderInfoService;

    @Resource
    private FrameworkContractInfoService frameworkContractInfoService;

    @Resource
    private MasterOrderGoodsService masterOrderGoodsService;

    @Resource
    private DepotInfoBeanService depotInfoBeanService;

    @Resource
    private FrameworkContractPriceInfoService frameworkContractPriceInfoService;

    @Resource
    private FrameworkContractAddressInfoService frameworkContractAddressInfoService;

    @Resource
    private FrameworkContractPayInfoService frameworkContractPayInfoService;

    @Resource
    private MasterOrderAddressInfoService masterOrderAddressInfoService;

    @Resource
    private ZgCallServiceUtils zgCallServiceUtils;

    @Resource
    private MasterOrderInfoExtendService masterOrderInfoExtendService;

    @Resource
    private MqSendService mqSendService;

    @Resource
    private MasterOrderInvoiceApplyDetailService masterOrderInvoiceApplyDetailService;

    @Resource
    private MasterOrderInvoiceApplyService masterOrderInvoiceApplyService;

    @Resource
    private ProductSellerGoodsOtherService productSellerGoodsOtherService; //自定义service

    @Resource
    private WarrantyService warrantyService;

    @Resource
    private UserCompanyService userCompanyService;

    /**
     * 短信服务
     */
    @Resource
    private SmsInfoBeanService smsInfoBeanService;

    @Resource
    private ProductLibCategoryExtMapper productLibCategoryExtMapper;
    /**
     * 开关查询
     */
    @Resource
    private CommonPublicInfoService commonPublicInfoService;
}
